<template>
  <div v-text="value"></div>
</template>

<script>
export default {
  name: 'Checkbox',
  props: {
    option: {
      type: Object,
      required: false,
      default: () => {
        return {
          options: []
        }
      }
    },
    fieldValue: {
      type: Array,
      required: false,
      default: () => {
        return [];
      }
    }
  },
  computed: {
    value() {
      let result = [];
      if (this.option.options && this.option.options.length === 0) {
        return result;
      }
      if (this.fieldValue && this.fieldValue.length > 0) {
        result = this.option.options.filter(item => this.fieldValue.includes(item.value)).map(item => item.label) || [];
      }
      return result.join('，');
    }
  }
}
</script>

<style scoped>

</style>